package com.xbell.dahua.demo.controller;

import com.xbell.dahua.demo.camera.DahuaWebCamera;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class WebCameraController {
    
    public static final String filename = "test.m3u8";

    private DahuaWebCamera webCamera;

    @PostMapping("/play")
    public ResponseEntity<String> play() {
        webCamera = new DahuaWebCamera();
        webCamera.init();
        webCamera.realPlay();
        return ResponseEntity.ok(filename);
//        return ResponseEntity.ok("success");
    }

    @PostMapping("/destroy")
    public ResponseEntity<String> destroy() {
        webCamera.destroy();
        return ResponseEntity.ok("success");
    }

}
